<?php


namespace Modules\Chinadmin\Services;


use Modules\Chinadmin\Models\CollectionLogModel;
use Modules\Chinadmin\Models\InvoiceLogModel;

/**
 * 订单处理逻辑
 * Class OrderServices
 * @package Modules\Chinadmin\Services
 */
class UserServices
{



    /**
     * @param CasesModel $casesModel
     * @return array
     * 采集记录
     */
    public function collectionRecord($page,$user_info){

        if(empty($page)){
            $page = 1;
        }

        $begin = ($page-1)*10;

        $data = CollectionLogModel::where('account_id',$user_info['id'])->offset($begin)->limit(10)->get();

        return $data;


    }

    /**
     * @param CasesModel $casesModel
     * @return array
     * 发票记录
     */
    public function invoiceRecord($i,$user_info){

        $page = $i['page'];

        if(empty($page)){
            $page = 1;
        }

        if(!(empty($i['state']) || $i['state'] == 'All')){
            $where[] = ['state', '=', $i['state']];
        }

        $begin = ($page-1)*10;
        $where[] = ['account_id', '=', $user_info['id']];

        $data['list'] = InvoiceLogModel::where($where)
            ->offset($begin)
            ->limit(10)
            ->get();

        $data['totalInvoiceAmount'] = InvoiceLogModel::where($where)
            ->sum('money');

        return $data;

    }


}
